package com.hxwang.tanke;

import java.awt.*;

/**
 * <H2> 爆炸类 </H2>
 *
 * @author hxwang
 * @data 2022/12/24
 */

public class Explode {
    private int x; // 坐标
    private int y; // 坐标
    private boolean living = true; // 是否活着

    public static final int EWIDTH = ResoourcesMgr.explodes[0].getWidth();
    public static final int EHEIGHT = ResoourcesMgr.explodes[0].getHeight();

    private TankFrame tf;

    public int step; // 记录爆炸的步骤

    public Explode(int x, int y, TankFrame tf) {
        this.x = x;
        this.y = y;
        this.tf = tf;
    }

    public Explode() {
    }

    public void paint(Graphics g) {
//        g.fillRect(x, y, 50, 50);
//        if (!living) {
//
//            return;
//        }
        Color c = g.getColor();
        g.drawImage(ResoourcesMgr.explodes[step++], x, y, null);
        if (step >= ResoourcesMgr.explodes.length) {
            tf.explodes.remove(this);
        }
        g.setColor(c);
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }


    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void die() {
        this.living = false;
    }
}

